<link rel="stylesheet" href="./theme/zui/css/min.css">
<script src="./js/jquery/lib.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
  .mainContent {
    text-align:center;
    padding-top:13%;
  }
  .logo {
    width:100px;
    height:100px;
    position:block;
  }
  h2 {
    text-align:center;
  }
  .progress {
    width:450px;
    height:20px;
    margin:auto;
    margin-top:20px;
  }
  .progress-bar {
    background-color:#33bc59;
  }
  .progress-message {
    margin-top:15px;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
  }
  .refreshButton {
    background-color:#33bc59;
    margin-top:35px;
    width:160px;
  }
</style>
<main id="main">
  <div class='mainContent'>
    <img class="logo" src="./theme/default/images/main/qucheng-logo.svg" />
    <h2>正在升级渠成Web服务</h2>
    <div class="progress progress-striped active">
      <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
      </div>
    </div>
    <div class="progress-message">
      备份数据...
    </div>
    <button class='btn btn-success btn-wide refreshButton' type="button" onclick="alert('正在升级中，请稍候！');"><i class="icon icon-refresh"></i><span class='text'>刷新</span></button>
  </div>
</main>
<script>
  var timerID= 0;
  function checkUpgradeStatus()
  {
      $.get('/backup-ajaxupgradestatus.html', function(response, status, xhr){
          res = JSON.parse(response);
          if((res.status == 'success' || res.status == 'overtime') && xhr.status == '200')
          {
              clearInterval(timerID);
              window.location.href = '/';
          }
      });
  }

  $(document).ready(function(){
      $.post('/backup-ajaxUpgradePlatform.html').done(function(response)
      {
          res = JSON.parse(response);
          if(res.result == 'success')
          {
              $('.progress-message').text('等待系统重启...');
              timerID = setInterval("checkUpgradeStatus()", 5000);

          }
          else
          {
              alert(res.message);
              window.location.href= '/backup-index.html';
          }
      });
  });
</script>
